package co.edu.usbcali.presentation.businessDelegate;

import co.edu.usbcali.modelo.Eventos;
import co.edu.usbcali.modelo.Foto;
import co.edu.usbcali.modelo.Imagenes;
import co.edu.usbcali.modelo.TipoEventos;
import co.edu.usbcali.modelo.control.Archivos;
import co.edu.usbcali.modelo.control.IEventosLogic;
import co.edu.usbcali.modelo.control.IImagenesLogic;
import co.edu.usbcali.modelo.control.ITipoEventosLogic;
import co.edu.usbcali.modelo.dto.EventosDTO;
import co.edu.usbcali.modelo.dto.ImagenesDTO;
import co.edu.usbcali.modelo.dto.TipoEventosDTO;
import java.util.List;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.StreamedContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Scope("singleton")
@Service("BusinessDelegatorView")
public class BusinessDelegatorView implements IBusinessDelegatorView {
    @Autowired
    private IEventosLogic eventosLogic;
    @Autowired
    private IImagenesLogic imagenesLogic;
    @Autowired
    private ITipoEventosLogic tipoEventosLogic;
    
    private Archivos archivo=new Archivos();

    @Override
    public List<Eventos> getEventos() throws Exception {
        return eventosLogic.getEventos();
    }

    @Override
    public void saveEventos(Eventos entity) throws Exception {
        eventosLogic.saveEventos(entity);
    }

    @Override
    public void deleteEventos(Eventos entity) throws Exception {
        eventosLogic.deleteEventos(entity);
    }

    @Override
    public void updateEventos(Eventos entity) throws Exception {
        eventosLogic.updateEventos(entity);
    }

    @Override
    public Eventos getEventos(Long idE) throws Exception {
        Eventos eventos = null;

        try {
            eventos = eventosLogic.getEventos(idE);
        } catch (Exception e) {
            throw e;
        }

        return eventos;
    }

    @Override
    public List<Eventos> findByCriteriaInEventos(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return eventosLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    @Override
    public List<Eventos> findPageEventos(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return eventosLogic.findPageEventos(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    @Override
    public Long findTotalNumberEventos() throws Exception {
        return eventosLogic.findTotalNumberEventos();
    }

    @Override
    public List<EventosDTO> getDataEventos() throws Exception {
        return eventosLogic.getDataEventos();
    }

    @Override
    public List<Imagenes> getImagenes() throws Exception {
        return imagenesLogic.getImagenes();
    }

    @Override
    public void saveImagenes(Imagenes entity) throws Exception {
        imagenesLogic.saveImagenes(entity);
    }

    @Override
    public void deleteImagenes(Imagenes entity) throws Exception {
        imagenesLogic.deleteImagenes(entity);
    }

    @Override
    public void updateImagenes(Imagenes entity) throws Exception {
        imagenesLogic.updateImagenes(entity);
    }

    @Override
    public Imagenes getImagenes(Long idImagen) throws Exception {
        Imagenes imagenes = null;

        try {
            imagenes = imagenesLogic.getImagenes(idImagen);
        } catch (Exception e) {
            throw e;
        }

        return imagenes;
    }

    @Override
    public List<Imagenes> findByCriteriaInImagenes(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return imagenesLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    @Override
    public List<Imagenes> findPageImagenes(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return imagenesLogic.findPageImagenes(sortColumnName, sortAscending,
            startRow, maxResults);
    }

    @Override
    public Long findTotalNumberImagenes() throws Exception {
        return imagenesLogic.findTotalNumberImagenes();
    }

    @Override
    public List<ImagenesDTO> getDataImagenes() throws Exception {
        return imagenesLogic.getDataImagenes();
    }

    @Override
    public List<TipoEventos> getTipoEventos() throws Exception {
        return tipoEventosLogic.getTipoEventos();
    }

    @Override
    public void saveTipoEventos(TipoEventos entity) throws Exception {
        tipoEventosLogic.saveTipoEventos(entity);
    }

    @Override
    public void deleteTipoEventos(TipoEventos entity) throws Exception {
        tipoEventosLogic.deleteTipoEventos(entity);
    }

    @Override
    public void updateTipoEventos(TipoEventos entity) throws Exception {
        tipoEventosLogic.updateTipoEventos(entity);
    }

    @Override
    public TipoEventos getTipoEventos(Integer idTe) throws Exception {
        TipoEventos tipoEventos = null;

        try {
            tipoEventos = tipoEventosLogic.getTipoEventos(idTe);
        } catch (Exception e) {
            throw e;
        }

        return tipoEventos;
    }

    @Override
    public List<TipoEventos> findByCriteriaInTipoEventos(Object[] variables,
        Object[] variablesBetween, Object[] variablesBetweenDates)
        throws Exception {
        return tipoEventosLogic.findByCriteria(variables, variablesBetween,
            variablesBetweenDates);
    }

    @Override
    public List<TipoEventos> findPageTipoEventos(String sortColumnName,
        boolean sortAscending, int startRow, int maxResults)
        throws Exception {
        return tipoEventosLogic.findPageTipoEventos(sortColumnName,
            sortAscending, startRow, maxResults);
    }

    @Override
    public Long findTotalNumberTipoEventos() throws Exception {
        return tipoEventosLogic.findTotalNumberTipoEventos();
    }

    @Override
    public List<TipoEventosDTO> getDataTipoEventos() throws Exception {
        return tipoEventosLogic.getDataTipoEventos();
    }
    
    @Override
    public void guardarArchivo(List<FileUploadEvent> file,Long idEvento)  throws Exception{
    	archivo.guardarArchivo(file, idEvento);
    }
    
    @Override
    public List<StreamedContent> obtenerArchivos(Long idEvento) throws Exception{
  
    	return archivo.obtenerArchivo(idEvento);
    }

    @Override
    public List<Foto> getImagenesPorEvento(long idEvento) throws Exception {
        return archivo.getImagenesPorEvento(idEvento);
    }
    
    
}
